<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="//g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js"></script>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<style type="text/css">
		.information {
			padding: 15px;
			display: flex;
		}

		.val {
			text-align: left;
		}

		.name {
			font-weight: 700;
		}

		.list {
			width: 30%;
			line-height: 30px;

		}

		.list1 {
			width: 70%;
			line-height: 30px;

		}

		.val {
			word-wrap: break-word;
		}

		.body {
			margin-top: 45px;
			background-color: #FFFFFF;
		}

		body {
			background-color: #FFFFFF;
		}

		.mui-btn {
			border-radius: 6px;
		}

		.title {
			padding: 20px;
			padding-bottom: 0px;
		}

		.information {
			padding: 15px;
			display: flex;
		}

		.val {
			text-align: left;
		}

		.name {
			font-weight: 700;
		}

		.list {
			width: 30%;
			line-height: 30px;

		}

		.list1 {
			width: 70%;
			line-height: 30px;

		}

		.val {
			word-wrap: break-word;
		}

		.fix {
			display: flex;
		}

		button {
			width: 100% !important;

		}

		.btn {
			padding: 20px;

		}

		span {
			font-weight: 700;
		}
	</style>
	<body>
		<script src="js/mui.js"></script>
		<script type="text/javascript">
			$(function() {
				//获取页面地址
				var ul = window.location.href;
				//切割地址获取到工号
				var badge = ul.split("=");
				var json = new Object();
				//被测量人的id
				var userId;
				//被测量人的工号
				json.badge = badge[1];
				//测量人的id
				var surveyorsUserId;
				dd.ready(function() {
					dd.runtime.permission.requestAuthCode({
						corpId: 'dingdd68e5ace8321d7a35c2f4657eb6378f', // 企业id
						onSuccess: function(info) {
							// 通过该免登授权码可以获取用户身份
							var jsond = new Object();
							jsond.authCode = info.code;
							$.ajax({
								url: route+'login',
								//将获取到的code传到后台
								data: JSON.stringify(jsond),
								headers: {
									"Content-Type": "application/json;charset=UTF-8"
								},
								dataType: 'json', //服务器返回json格式数据
								type: 'post', //HTTP请求类型
								success: function(data) {
									surveyorsUserId = data.userId;
								
								},
								error: function(XMLHttpRequest, textStatus, errorThrown) {
									//alert(textStatus); 
								}
							});
						},
						onFail: function(err) {
							//alert(JSON.stringify(data));
						},
				
					});
				
				});
				

				$.ajax({
					url: route+'findUserByBadge',
					//将获取到的badge传到后台
					data: JSON.stringify(json),
					headers: {
						"Content-Type": "application/json;charset=UTF-8"
					},
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					success: function(data) {
						//将用户信息渲染到页面
						$("#name1").text(data.name);
						$("#name2").text(data.position);
						$("#name3").text(data.jobNumber);
						$("#name4").text(data.mobile);
						userId=data.userId;


					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						alert(textStatus);
					}
				});

				$("#b").click(function() {
					//获取各个单选框的值
					var isFever = $('input:radio[name="isFever"]:checked').val();
					var isDiscomfort = $('input:radio[name="isDiscomfort"]:checked').val();
                    var surveyorsPlace=$(".place").val();
					//将获取到的值打包成JSON
					var jsons = new Object();
					jsons.surveyorsUserId = surveyorsUserId;
					jsons.isFever = isFever;
					jsons.isDiscomfort = isDiscomfort;
					jsons.userId = userId;
					jsons.surveyorsPlace=surveyorsPlace;
					jsons.badge=badge[1];
					//判断每道题是否都填写
					if (surveyorsPlace==""||isFever == undefined || isDiscomfort == undefined) {
						alert("请检查每道题是否填写！");
						return false;

					} else {
						
						$.ajax({
							url: route+'investigation/heMeasured',
							//将打包好的JSON传到后台
							data: JSON.stringify(jsons),
							headers: {
								"Content-Type": "application/json;charset=UTF-8"
							},
							dataType: 'json', //服务器返回json格式数据
							type: 'post', //HTTP请求类型
							success: function(data) {
								//判断code等于0则提示提交成功
								if (data.code == 0) {
									alert("提交成功！");
									mui.openWindow({
										//返回主页
										url: "./index.html"
									})
								} else {
									alert("提交失败，请联系管理员！");
								}



							},
							error: function(XMLHttpRequest, textStatus, errorThrown) {
								alert(textStatus);
							}
						});
					}

				})



			})
		</script>
		<!-- mui顶部导航栏 -->
		<header class="mui-bar mui-bar-nav mui-bar-nav-bg">
			<a id="icon-menu" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<a class="mui-action-back mui-icon mui-icon-home mui-pull-right mui-a-color"></a>
			<h1 class="mui-title">新冠肺炎防疫调查</h1>
		</header>
		<div class="body">
			<!-- 用户信息 -->
			<div class="information">
				<div class="list">
					<div class="name ">
						姓名:
					</div>
					<div class="name ">
						岗位名称:
					</div>
					<div class="name ">
						岗位编号:
					</div>
					<div class="name ">
						手机号码:
					</div>
					

				</div>
				<div class="list1">
					<div id="name1" class="val name1">

					</div>
					<div id="name2" class="val name2">

					</div>
					<div id="name3" class="val name3">

					</div>
					<div id="name4" class="val name4">

					</div>


				</div>
			</div>
			<!-- 题目 -->
			<div class="title">
				<span>请输入检测地点</span>
				<input type="text" placeholder="请输入检测地点" class="place" value="" />
			</div>
			<div class="title">
				<span>1.当前体温是否大于37.2°？</span>
				<div class="fix">
					<div class="mui-input-row mui-radio mui-left">
						<label>是</label>
						<input name="isFever" type="radio" value="1">

					</div>
					<div class="mui-input-row mui-radio mui-left">
						<label>否</label>
						<input name="isFever" type="radio" value="0">

					</div>
				</div>


			</div>
			<div class="title">
				<span>2.是否有乏力、干咳、呕吐、感冒等身体不适症状？</span>
				<div class="fix">
					<div class="mui-input-row mui-radio mui-left">
						<label>是</label>
						<input name="isDiscomfort" type="radio" value="1">

					</div>
					<div class="mui-input-row mui-radio mui-left">
						<label>否</label>
						<input name="isDiscomfort" type="radio" value="0">

					</div>
				</div>


			</div>
			<!-- 底部按钮 -->
			<div class="btn">
				<button type="button" class="mui-btn mui-btn-blue" id="b">提交</button>
			</div>
		</div>

	</body>

</html>
